package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.CPService;
import com.yixun.qfbao.apidto.GetCPStatisticsByPremisesReqDto;
import com.yixun.qfbao.apidto.GetCPStatisticsByPremisesResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetCPStatisticsByPremisesReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 巧渠道首页报备统计
 * 客户总量、昨日新增及待审数量
 * @author JHSong
 * 		
 */
@Service("getCPStatisticsByPremisesHander")
public class GetCPStatisticsByPremisesHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(GetCPStatisticsByPremisesHander.class);
	
	@Autowired
	private CPService cpService;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetCPStatisticsByPremisesReqVo req = (GetCPStatisticsByPremisesReqVo)reqDto;
		GetCPStatisticsByPremisesReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetCPStatisticsByPremisesResDto> res = new BaseResponseDTO<GetCPStatisticsByPremisesResDto>();
		GetCPStatisticsByPremisesResDto resDto = new GetCPStatisticsByPremisesResDto();
		try {
			resDto = cpService.getCPStatisticsByPremises(reqDto1);
		} catch (Exception e) {
			logger.error("GetCPStatisticsByPremisesHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("报备人员数量统计!");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
